<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>🔧 最新修复测试</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; background: #f5f5f5; }
        .container { max-width: 1200px; margin: 0 auto; }
        .test-result { margin: 10px 0; padding: 15px; border-radius: 8px; }
        .success { background-color: #d4edda; color: #155724; border-left: 4px solid #28a745; }
        .error { background-color: #f8d7da; color: #721c24; border-left: 4px solid #dc3545; }
        .title { font-size: 24px; margin-bottom: 20px; }
        .subtitle { font-size: 16px; color: #666; margin-bottom: 30px; }
        .fixed-tag { background: #28a745; color: white; padding: 2px 6px; border-radius: 3px; font-size: 12px; }
        pre { background: #f8f9fa; padding: 10px; border-radius: 5px; overflow-x: auto; font-size: 12px; }
    </style>
</head>
<body>
    <div class="container">
        <h1 class="title">🔧 最新修复验证</h1>
        <p class="subtitle">测试VAL_负数值 + 简化注释格式修复</p>
        
        <div id="test-results"></div>
    </div>
    
    <script src="dbc-parser.js"></script>
    <script>
        const problematicFiles = [
            { name: 'ford_lincoln_base_pt.dbc', issue: 'VAL_负数值 (-1, -2)' },
            { name: 'tesla_can.dbc', issue: 'VAL_负数值 (-4096)' },
            { name: 'tesla_model3_party.dbc', issue: 'VAL_负数值 (-32768)' },
            { name: 'tesla_powertrain.dbc', issue: 'VAL_负数值 (-4096)' },
            { name: 'hyundai_kia_generic.dbc', issue: '简化注释格式 (CM_ 145)' }
        ];
        
        async function runFixTest() {
            const results = document.getElementById('test-results');
            
            for (const file of problematicFiles) {
                const resultDiv = document.createElement('div');
                resultDiv.className = 'test-result';
                
                try {
                    console.log(`测试修复: ${file.name} (${file.issue})`);
                    const response = await fetch(file.name);
                    const content = await response.text();
                    
                    const startTime = performance.now();
                    const result = parseDBCContent(content, file.name);
                    const endTime = performance.now();
                    const duration = Math.round(endTime - startTime);
                    
                    resultDiv.className += ' success';
                    resultDiv.innerHTML = `
                        <strong>✅ ${file.name}</strong> <span class="fixed-tag">已修复</span><br>
                        <small>${file.issue}</small><br>
                        ${duration}ms | ${result.frames.length}帧 | 
                        ${result.frames.reduce((sum, f) => sum + f.signals.length, 0)}信号 | 
                        ${result.warnings.length}警告
                    `;
                    
                    console.log(`✅ ${file.name}: 修复成功!`);
                    
                } catch (error) {
                    resultDiv.className += ' error';
                    resultDiv.innerHTML = `
                        <strong>❌ ${file.name}</strong><br>
                        <small>${file.issue}</small><br>
                        <strong>错误:</strong> ${error.message}
                        <pre>${error.stack}</pre>
                    `;
                    console.error(`❌ ${file.name}:`, error);
                }
                
                results.appendChild(resultDiv);
            }
            
            // 总结
            const successCount = document.querySelectorAll('.success').length;
            const totalCount = problematicFiles.length;
            
            const summaryDiv = document.createElement('div');
            summaryDiv.style.cssText = 'margin-top: 30px; padding: 20px; background: #e3f2fd; border-radius: 8px; text-align: center;';
            summaryDiv.innerHTML = `
                <h3>🎯 修复结果总结</h3>
                <p><strong>${successCount}/${totalCount}</strong> 个问题文件已修复</p>
                <p>修复率: <strong>${Math.round(successCount/totalCount*100)}%</strong></p>
            `;
            results.appendChild(summaryDiv);
        }
        
        runFixTest();
    </script>
</body>
</html> 